class FieldTransformAction {
    constructor() {
        this.filterActionType = "field-transform"
    }
    createInitParam(action) {
        action.params["methodType"] = action.params["methodType"] || "toList"; // 固定方法
        action.params["customMethod"] = action.params["customMethod"] || "";   // 自定义方法
    }
    renderActionConfig(action) {
        let html = `
          <div class="form-group">
            <label>字段</label>
            <input type="text" id="actionField" value="${action.field || ''}" />
          </div>
          <div class="form-group">
            <label>目标字段</label>
            <input type="text" id="actionTargetField" value="${action.targetField || ''}" />
          </div>
          <div class="form-group">
            <label>处理方法</label>
            <select id="actionMethodType">
              <option value="fromCSV" ${action.params["methodType"] === "fromCSV" ? "selected" : ""}>fromCSV</option>
              <option value="toCSV" ${action.params["methodType"] === "toCSV" ? "selected" : ""}>toCSV</option>
              <option value="userDefine" ${action.params["methodType"] === "userDefine" ? "selected" : ""}>userDefine</option>
            </select>
          </div>
           <div class="form-group">
            <label>自定义处理JS方法</label>
            <input type="text" id="actionCustomMethod" value="${action.params["customMethod"] || ''}" />
          </div>
        `;
        return html;
    }
    collectActionConfig(action) {
        action.field = document.getElementById("actionField")?.value;
        action.targetField = document.getElementById("actionTargetField")?.value;
        action.params["methodType"] = document.getElementById("actionMethodType")?.value;
        action.params["customMethod"] = document.getElementById("actionCustomMethod")?.value;
    }
}
export default new FieldTransformAction();
